package com.noyes4j.device.service.impl;

import com.noyes4j.common.core.text.Convert;
import com.noyes4j.common.utils.DateUtils;
import com.noyes4j.device.domain.SysDevice;
import com.noyes4j.device.mapper.SysDeviceMapper;
import com.noyes4j.device.service.ISysDeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName SysDeviceServiceImpl
 * @Description: TODO
 * @Author zhaoweiqin
 * @Date 2021/1/29
 * @Version V1.0
 **/
@Service
public class SysDeviceServiceImpl implements ISysDeviceService {
    @Autowired
    private SysDeviceMapper sysDeviceMapper;

    /**
     * 查询设备
     *
     * @param id 设备ID
     * @return 设备
     */
    @Override
    public SysDevice selectSysDeviceById(Long id)
    {
        return sysDeviceMapper.selectSysDeviceById(id);
    }

    /**
     * 查询设备列表
     *
     * @param sysDevice 设备
     * @return 设备
     */
    @Override
    public List<SysDevice> selectSysDeviceList(SysDevice sysDevice)
    {
        return sysDeviceMapper.selectSysDeviceList(sysDevice);
    }

    /**
     * 新增设备
     *
     * @param sysDevice 设备
     * @return 结果
     */
    @Override
    public int insertSysDevice(SysDevice sysDevice)
    {
        sysDevice.setCreateTime(DateUtils.getNowDate());
        return sysDeviceMapper.insertSysDevice(sysDevice);
    }

    /**
     * 修改设备
     *
     * @param sysDevice 设备
     * @return 结果
     */
    @Override
    public int updateSysDevice(SysDevice sysDevice)
    {
        sysDevice.setUpdateTime(DateUtils.getNowDate());
        return sysDeviceMapper.updateSysDevice(sysDevice);
    }

    /**
     * 删除设备对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteSysDeviceByIds(String ids)
    {
        return sysDeviceMapper.deleteSysDeviceByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除设备信息
     *
     * @param id 设备ID
     * @return 结果
     */
    @Override
    public int deleteSysDeviceById(Long id)
    {
        return sysDeviceMapper.deleteSysDeviceById(id);
    }
}
